/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sais.eswn.card;

import org.sais.eswn.tool.Tools;

/**
 *
 * @author Romulus
 */
public class CardText {

    private float cost;
    private String user;
    private Bullet fire;
    private Bullet conquer;
    private String ruleText;
    private String timing;

    public CardText(float cost, String user, Bullet fire, Bullet conquer, String timing, String ruleText) {
        this.cost = cost;
        this.user = user;
        this.fire = fire;
        this.conquer = conquer;
        this.timing = timing;
        this.ruleText = ruleText;
    }

    public String getDisplayText(int type) {
        StringBuilder ret = new StringBuilder();
        switch (type) {
            case Card.CARDTYPE_SPELL:
                ret.append(Tools.getLoc(5) + cost + "\n\n");
                ret.append(Tools.getLoc(6) + user + "\n");
                ret.append(Tools.getLoc(7) + fire.getDisplayText() + "\n");
                ret.append(Tools.getLoc(8) + conquer.getDisplayText() + "\n");
                ret.append("\n");
                ret.append(ruleText + "\n");
                return ret.toString();
            case Card.CARDTYPE_EVENT:
                ret.append(Tools.getLoc(17) + (int) cost + "\n\n");
                ret.append(Tools.getLoc(6) + user + "\n");
                ret.append(Tools.getLoc(18) + timing + "\n");
                ret.append("\n");
                ret.append(ruleText + "\n");
                return ret.toString();
            default:
                return "";
        }
    }

    public String getExportText(int type) {
        StringBuilder ret = new StringBuilder();
        switch (type) {
            case Card.CARDTYPE_SPELL:
                ret.append(Tools.getLoc(5) + cost + "\r\n");
                ret.append(Tools.getLoc(6) + user + "\r\n");
                ret.append(Tools.getLoc(7) + fire.getDisplayText() + "\r\n");
                ret.append(Tools.getLoc(8) + conquer.getDisplayText() + "\r\n");
                ret.append(ruleText + "\r\n");
                return ret.toString();
            case Card.CARDTYPE_EVENT:
                ret.append(Tools.getLoc(17) + (int) cost + "\r\n");
                ret.append(Tools.getLoc(6) + user + "\r\n");
                ret.append(Tools.getLoc(18) + timing + "\r\n");
                ret.append(ruleText + "\r\n");
                return ret.toString();
            default:
                return "";
        }
    }

    public Bullet getFire() {
        return fire;
    }

    public Bullet getConquer() {
        return conquer;
    }

    public float getCost() {
        return cost;
    }

    public String getUser() {
        return user;
    }

    public static class CardTextBuilder {

        public float cost;
        public String user;
        public Bullet fire = new Bullet();
        public Bullet conquer = new Bullet();
        public String timing = "";
        public String ruleText = "";

        public CardText build() {
            return new CardText(cost, user, fire, conquer, timing, ruleText);
        }
    }
}
